package oo

import (
	"elegantGo/chapter02-2/pkg/validate"
)

type Phone struct {
	String
}

func (o *Phone) IsValid() bool {
	return validate.Var(o.value, "number,len=11,startswith=1,startsnotwith=11,startsnotwith=12") == nil
}

func (o *Phone) Mask() string {
	return o.value[0:4] + "****" + o.value[8:11]
}

func (o *Phone) GenNickname() string {
	return o.Mask()
}
